<?php
namespace app\common\repositories\apps;


use app\common\repositories\BaseRepository;
use app\common\dao\apps\AppsEventDao;

use think\facade\Db;

class AppsEventRepository extends BaseRepository
{
    protected $dao;
    public function __construct(){
        $this->dao = new AppsEventDao();
    }

    /**
     * @desc: create one AppsAccess
     * @param varchar $appkey 
     * @param varchar $device 
     * @param varchar $custom 
     * @author: generate
     */
    public function createOneAppsEvent(
        $appkey,
        $device = '',
        $custom = '',
        $fingerprint = '',
        $version = ''
    ) {
        
        // to do  some check
        $data = compact('appkey','custom','device','fingerprint','version');

        $data['is_del'] = 0;
        $data['create_at'] =  date('Y-m-d H:i:s');

        $id = Db::transaction(function () use($data) {
            $id = $this->create($data);
            // todo other

            return $id;
        });

        return ['code' => 200, 'msg' => 'ok', 'data' => ['id' => $id]];
    }

}